<template>
  <div>
    <div id="myChart" :style="{width: '600px', height: '600px'}"></div>
  </div>
</template>

<script>
import request from '@/utils/request'
export default {
  name: 'hello',
  data () {
    return {
      msg: 'Welcome to Your Vue.js App',
      echartsX: [],
      echartsY: []
    }
  },
  mounted () {
    request({
      url: '/pay/findWeekGroupByList',
      method: 'get'
    }).then((res) => {
      if (res.code === '00000000') {
        for (let i = 0; i < res.data.dataList.length; i++) {
          this.echartsX.push(res.data.dataList[i].time)
          this.echartsY.push(res.data.dataList[i].sumMoney / 100)
        }
        this.drawLine()
      }
    })
  },
  methods: {
    drawLine () {
      // 基于准备好的dom，初始化echarts实例
      let myChart = this.$echarts.init(document.getElementById('myChart'))
      // 绘制图表
      myChart.setOption({
        title: { text: '近12月资产营业收入表' },
        tooltip: {},
        xAxis: {
          data: this.echartsX
        },
        yAxis: {},
        series: [{
          name: '收入(元)',
          type: 'bar',
          data: this.echartsY
        }]
      })
    }
  }
}
</script>

<style>
</style>
